$(function() {

    var updateList = chrome.extension.getBackgroundPage().updateList;
    
    if (!updateList || !updateList.length || updateList.length <= 0) {
        self.close();
        return false;
    }

    $("#link").attr("href", "http://" + HOSTNAME + "/home");

    $("#count").text(updateList.length);

    var dl = $("dl");

    for(var i=0, l=updateList.length; i<l; i++) {

        var status = updateList[i];

        var name = $("user > name", status).text()||$("user > screen_name", status).text();
//      var imgsrc = $("user > profile_image_url", status).text();
        var created = new Date($("created_at", status).text()).formatJa();
        var text = $("text", status).text();

        console.log(i + ": " + JSON.stringify({"name":name, "date": created, "text": text}));

        var dt = $("<DT/>")
//          .append("<IMG class='icon' width='16px' height='16px' src='../images/notify.gif'/>")
            .append("<SPAN class='user'>" + name + "</SPAN>")
            .append("<SPAN class='created_at'>(" + created + ")</SPAN>");
            
        var dd = $("<DD/>").append(text);

        dl.append(dt).append(dd);
    }
})();
